//
//@File    :	10.11_stack.cpp
//@Time    :	2021/08/28 22:39:07
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	Stack member functions
//

#include "10.10_stack.h"

Stack::Stack()
{
    top = 0;
}

bool Stack::isempty() const
{
    return top == 0;
}

bool Stack::isfull() const
{
    return top == MAX;
}

bool Stack::push(const Item &item)
{
    if (top < MAX)
    {
        items[top++] = item;
        return true;
    }
    else
    {
        return false;
    }
}
bool Stack::pop(Item & item)
{
    if (top>0)
    {
        item = items[--top];
        return true;
    }
    else
    {
        return false;
    }
    
}